﻿(function(){

// 遍历框架
function TraverseFrames(win,fn)
{
	if (!win) return;
	fn(win);

	var o = win.frames;
	if (!o) return;
	for (var i=0,len=o.length; i<len; i++){
		TraverseFrames(o[i], fn);
	}
}

var rt = window.external.mxGetRuntime();
var email = [];

// 循环所有框架页，分析并提取
TraverseFrames(window, function(win){
	var s = win.document.body.innerHTML;
	var exp = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/g;
	var mail = s.match(exp);
	if (mail) email = email.concat( s.match(exp) );
});

// 提取到数据，则发送消息
if (email.length > 0){
	rt.post('capture', email);
}

})();
